package com.project.common.domain.entity;

import com.project.common.domain.po.BaseAutoKeyPO;
import io.swagger.v3.oas.annotations.media.Schema;
import javax.persistence.Column;
import javax.persistence.MappedSuperclass;
import javax.persistence.Transient;
import lombok.Data;
import org.springframework.data.annotation.CreatedBy;
import org.springframework.data.annotation.CreatedDate;
import org.springframework.data.annotation.LastModifiedBy;
import org.springframework.data.annotation.LastModifiedDate;

import java.time.LocalDateTime;
import java.util.List;

/**
 * @author: 陈刚
 * @blame:
 * @date: 2022/10/3 23:16
 **/
@Data
@MappedSuperclass
public class Menu extends BaseAutoKeyPO {
    @Schema(description = "创建人")
    @CreatedBy
    @Column(name = "create_by")
    private Long createBy;

    @Schema(description = "创建时间")
    @Column(name = "create_time")
    @CreatedDate
    private LocalDateTime createTime;

    @Schema(description = "更新时间")
    @LastModifiedDate
    @Column(name = "update_time")
    private LocalDateTime updateTime;

    @Schema(description = "更新人")
    @CreatedBy
    @LastModifiedBy
    @Column(name = "update_by")
    private Long updateBy;

    @Schema(description = "父级id")
    @Column(columnDefinition = "bigint DEFAULT NULL COMMENT '父级id'")
    private Long pid;

    @Schema(description = "名称")
    @Column(columnDefinition = "varchar(32) DEFAULT NULL COMMENT '名称'")
    private String name;

    @Schema(description = "路径")
    @Column(columnDefinition = "varchar(100) DEFAULT NULL COMMENT '路径'")
    private String path;

    @Schema(description = "组件地址")
    @Column(columnDefinition = "varchar(200) DEFAULT NULL COMMENT '组件地址'")
    private String component;

    @Schema(description = "显示顺序")
    @Column(columnDefinition = "int DEFAULT NULL COMMENT '显示顺序'")
    private Integer sort;

    @Schema(description = "平台类型（1-管理端，2-运营端）")
    @Column(columnDefinition = "tinyint(3) DEFAULT '1' COMMENT '平台类型（1-管理端，2-运营端）'")
    private Integer type;

    @Schema(description = "展示类（1-平台用户，2-开发用户，3-企业用户，4-公共用户）")
    @Column(columnDefinition = "tinyint(3) DEFAULT '1' COMMENT '展示类型（1-平台用户，2-开发用户，3-企业用户，4-公共用户）'")
    private Integer showType;

    @Schema(description = "状态（1正常，2禁用）")
    @Column(columnDefinition = "tinyint(3) DEFAULT '1' COMMENT '状态（1正常，2禁用）'")
    private Integer status;

    @Schema(description = "图标")
    @Column(columnDefinition = "varchar(32) DEFAULT NULL COMMENT '图标'")
    private String icon;

    @Schema(description = "备注")
    private String remark;

    @Schema(description = "是否为外链（1是 0否）")
    @Column(columnDefinition = "tinyint(3) DEFAULT '1' COMMENT '是否为外链（1是 0否）'")
    private Integer isFrame;

    @Schema(description = "显示状态（1显示 0隐藏）")
    @Column(columnDefinition = "tinyint(3) DEFAULT '1' COMMENT '显示状态（1显示 0隐藏）'")
    private Integer visible;

    @Schema(description = "菜单类型（M目录 C菜单 F按钮 O其他）")
    @Column(columnDefinition = "char(1) DEFAULT '' COMMENT '菜单类型（M目录 C菜单 F按钮 O其他）'")
    private String menuType;

    @Schema(description = "上级的path")
    @Column(columnDefinition = "varchar(64) DEFAULT '' COMMENT '上级的path'")
    private String activeMenu;

    @Schema(description = "重定向")
    @Column(columnDefinition = "varchar(128) DEFAULT '' COMMENT '重定向'")
    private String redirect;

    @Transient
    private List<Menu> children;
}
